import React, { useState } from 'react';
import { DatePicker } from 'antd';

const { RangePicker } = DatePicker;

const SelectTime = () => {
    const [dates, setDates] = useState([]);
    const disabledDate = current => {
        console.log(1)
        if (!dates || dates.length === 0) {
            return false;
        }
        console.log(current.diff(dates[0], 'days') > 3)
        const tooLate = dates[0] && current.diff(dates[0], 'days') > 3;
        const tooEarly = dates[1] && dates[1].diff(current, 'days') > 3;
        return tooEarly || tooLate;
    };

    return (
        <RangePicker
            disabledDate={disabledDate}
            onCalendarChange={value => {
                console.log(value)
                setDates(value);
            }}
        />
    );
};

export default SelectTime;